\hypertarget{compress_8c}{}\doxysubsection{extern/libembroidery/src/compress.c File Reference}
\label{compress_8c}\index{extern/libembroidery/src/compress.c@{extern/libembroidery/src/compress.c}}
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include \char`\"{}embroidery\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{compress_8c_a053addffe32629b6727073e9c499cc32}{hus\+\_\+compress}} (char $\ast$data, int length, char $\ast$output, int $\ast$output\+\_\+length)
\item 
void \mbox{\hyperlink{compress_8c_a7e5d1d3488d7124ab020287e2606f89d}{huffman\+\_\+build\+\_\+table}} (\mbox{\hyperlink{embroidery__internal_8h_a8ad0df962f28b81981b3b0b7f04ebb17}{huffman}} $\ast$h)
\item 
int $\ast$ \mbox{\hyperlink{compress_8c_a04af50a7e18d0e4d85ae76c7c4bd80d9}{huffman\+\_\+lookup}} (\mbox{\hyperlink{embroidery__internal_8h_a8ad0df962f28b81981b3b0b7f04ebb17}{huffman}} h, int byte\+\_\+lookup)
\item 
void \mbox{\hyperlink{compress_8c_ac2630b57677982cec1d413de85c262fd}{compress\+\_\+init}} ()
\item 
int \mbox{\hyperlink{compress_8c_aed62fb2531905dbb3a075afb3912c50e}{compress\+\_\+get\+\_\+bits}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c, int length)
\item 
int \mbox{\hyperlink{compress_8c_af511532a8a7f9f6646379e8fbb472331}{compress\+\_\+pop}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c, int bit\+\_\+count)
\item 
int \mbox{\hyperlink{compress_8c_aaeb1b13beaf29fad4611aca96a32b499}{compress\+\_\+peek}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c, int bit\+\_\+count)
\item 
int \mbox{\hyperlink{compress_8c_afb74b97766d1968313b6e637032e9686}{compress\+\_\+read\+\_\+variable\+\_\+length}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
void \mbox{\hyperlink{compress_8c_aa237ee1cf527ebb720fccf48495179e1}{compress\+\_\+load\+\_\+character\+\_\+length\+\_\+huffman}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
void \mbox{\hyperlink{compress_8c_a39e722c76e45536e81a47b35c349eb79}{compress\+\_\+load\+\_\+character\+\_\+huffman}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
void \mbox{\hyperlink{compress_8c_a7830b6991ed529226a1a7252d29b401e}{compress\+\_\+load\+\_\+distance\+\_\+huffman}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
void \mbox{\hyperlink{compress_8c_a58b1553ebfc0984e0d9ef74bcbb14c0c}{compress\+\_\+load\+\_\+block}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
int \mbox{\hyperlink{compress_8c_a8a9394d4a8d2bd617070539667405633}{compress\+\_\+get\+\_\+token}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
int \mbox{\hyperlink{compress_8c_a61b95342f1dbd1e438079d87b3837da6}{compress\+\_\+get\+\_\+position}} (\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$c)
\item 
int \mbox{\hyperlink{compress_8c_aa5370ff498be6c8a440bb0a581c2ed5c}{hus\+\_\+decompress}} (char $\ast$data, int length, char $\ast$output, int $\ast$output\+\_\+length)
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{compress_8c_af0a0646ec730d0abdffced84a07f845e}{huffman\+\_\+lookup\+\_\+data}} \mbox{[}2\mbox{]}
\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
This is a work in progress.

Thanks to Jason Weiler for describing the binary formats of the HUS and VIP formats at\+:

\href{http://www.jasonweiler.com/HUSandVIPFileFormatInfo.html}{\texttt{ http\+://www.\+jasonweiler.\+com/\+HUSand\+VIPFile\+Format\+Info.\+html}}

Further thanks to github user tatarize for solving the mystery of the compression in\+:

\href{https://github.com/EmbroidePy/pyembroidery}{\texttt{ https\+://github.\+com/\+Embroide\+Py/pyembroidery}}

with a description of that work here\+:

\href{https://stackoverflow.com/questions/7852670/greenleaf-archive-library}{\texttt{ https\+://stackoverflow.\+com/questions/7852670/greenleaf-\/archive-\/library}}

This is based on their work. 

\doxysubsubsection{Function Documentation}
\mbox{\Hypertarget{compress_8c_aed62fb2531905dbb3a075afb3912c50e}\label{compress_8c_aed62fb2531905dbb3a075afb3912c50e}} 
\index{compress.c@{compress.c}!compress\_get\_bits@{compress\_get\_bits}}
\index{compress\_get\_bits@{compress\_get\_bits}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_get\_bits()}{compress\_get\_bits()}}
{\footnotesize\ttfamily int compress\+\_\+get\+\_\+bits (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c,  }\item[{int}]{length }\end{DoxyParamCaption})}

{\itshape c} {\itshape length} Returns . \mbox{\Hypertarget{compress_8c_a61b95342f1dbd1e438079d87b3837da6}\label{compress_8c_a61b95342f1dbd1e438079d87b3837da6}} 
\index{compress.c@{compress.c}!compress\_get\_position@{compress\_get\_position}}
\index{compress\_get\_position@{compress\_get\_position}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_get\_position()}{compress\_get\_position()}}
{\footnotesize\ttfamily int compress\+\_\+get\+\_\+position (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c} . Returns the position as an int. \mbox{\Hypertarget{compress_8c_a8a9394d4a8d2bd617070539667405633}\label{compress_8c_a8a9394d4a8d2bd617070539667405633}} 
\index{compress.c@{compress.c}!compress\_get\_token@{compress\_get\_token}}
\index{compress\_get\_token@{compress\_get\_token}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_get\_token()}{compress\_get\_token()}}
{\footnotesize\ttfamily int compress\+\_\+get\+\_\+token (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c} . Returns the token as an int. \mbox{\Hypertarget{compress_8c_ac2630b57677982cec1d413de85c262fd}\label{compress_8c_ac2630b57677982cec1d413de85c262fd}} 
\index{compress.c@{compress.c}!compress\_init@{compress\_init}}
\index{compress\_init@{compress\_init}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_init()}{compress\_init()}}
{\footnotesize\ttfamily void compress\+\_\+init (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compress_8c_a58b1553ebfc0984e0d9ef74bcbb14c0c}\label{compress_8c_a58b1553ebfc0984e0d9ef74bcbb14c0c}} 
\index{compress.c@{compress.c}!compress\_load\_block@{compress\_load\_block}}
\index{compress\_load\_block@{compress\_load\_block}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_load\_block()}{compress\_load\_block()}}
{\footnotesize\ttfamily void compress\+\_\+load\+\_\+block (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c} . Returns nothing. \mbox{\Hypertarget{compress_8c_a39e722c76e45536e81a47b35c349eb79}\label{compress_8c_a39e722c76e45536e81a47b35c349eb79}} 
\index{compress.c@{compress.c}!compress\_load\_character\_huffman@{compress\_load\_character\_huffman}}
\index{compress\_load\_character\_huffman@{compress\_load\_character\_huffman}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_load\_character\_huffman()}{compress\_load\_character\_huffman()}}
{\footnotesize\ttfamily void compress\+\_\+load\+\_\+character\+\_\+huffman (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

Load character table to compress struct {\itshape c}. Returns nothing. \mbox{\Hypertarget{compress_8c_aa237ee1cf527ebb720fccf48495179e1}\label{compress_8c_aa237ee1cf527ebb720fccf48495179e1}} 
\index{compress.c@{compress.c}!compress\_load\_character\_length\_huffman@{compress\_load\_character\_length\_huffman}}
\index{compress\_load\_character\_length\_huffman@{compress\_load\_character\_length\_huffman}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_load\_character\_length\_huffman()}{compress\_load\_character\_length\_huffman()}}
{\footnotesize\ttfamily void compress\+\_\+load\+\_\+character\+\_\+length\+\_\+huffman (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c} . Returns. \mbox{\Hypertarget{compress_8c_a7830b6991ed529226a1a7252d29b401e}\label{compress_8c_a7830b6991ed529226a1a7252d29b401e}} 
\index{compress.c@{compress.c}!compress\_load\_distance\_huffman@{compress\_load\_distance\_huffman}}
\index{compress\_load\_distance\_huffman@{compress\_load\_distance\_huffman}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_load\_distance\_huffman()}{compress\_load\_distance\_huffman()}}
{\footnotesize\ttfamily void compress\+\_\+load\+\_\+distance\+\_\+huffman (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c} . Returns nothing. \mbox{\Hypertarget{compress_8c_aaeb1b13beaf29fad4611aca96a32b499}\label{compress_8c_aaeb1b13beaf29fad4611aca96a32b499}} 
\index{compress.c@{compress.c}!compress\_peek@{compress\_peek}}
\index{compress\_peek@{compress\_peek}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_peek()}{compress\_peek()}}
{\footnotesize\ttfamily int compress\+\_\+peek (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c,  }\item[{int}]{bit\+\_\+count }\end{DoxyParamCaption})}

{\itshape c} {\itshape bit\+\_\+count}. Returns. \mbox{\Hypertarget{compress_8c_af511532a8a7f9f6646379e8fbb472331}\label{compress_8c_af511532a8a7f9f6646379e8fbb472331}} 
\index{compress.c@{compress.c}!compress\_pop@{compress\_pop}}
\index{compress\_pop@{compress\_pop}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_pop()}{compress\_pop()}}
{\footnotesize\ttfamily int compress\+\_\+pop (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c,  }\item[{int}]{bit\+\_\+count }\end{DoxyParamCaption})}

{\itshape c} {\itshape bit\+\_\+count} . Returns. \mbox{\Hypertarget{compress_8c_afb74b97766d1968313b6e637032e9686}\label{compress_8c_afb74b97766d1968313b6e637032e9686}} 
\index{compress.c@{compress.c}!compress\_read\_variable\_length@{compress\_read\_variable\_length}}
\index{compress\_read\_variable\_length@{compress\_read\_variable\_length}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{compress\_read\_variable\_length()}{compress\_read\_variable\_length()}}
{\footnotesize\ttfamily int compress\+\_\+read\+\_\+variable\+\_\+length (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a0a1ded23c1c333067bcfb59d5b83ce2a}{compress}} $\ast$}]{c }\end{DoxyParamCaption})}

{\itshape c}. Returns. \mbox{\Hypertarget{compress_8c_a7e5d1d3488d7124ab020287e2606f89d}\label{compress_8c_a7e5d1d3488d7124ab020287e2606f89d}} 
\index{compress.c@{compress.c}!huffman\_build\_table@{huffman\_build\_table}}
\index{huffman\_build\_table@{huffman\_build\_table}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{huffman\_build\_table()}{huffman\_build\_table()}}
{\footnotesize\ttfamily void huffman\+\_\+build\+\_\+table (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a8ad0df962f28b81981b3b0b7f04ebb17}{huffman}} $\ast$}]{h }\end{DoxyParamCaption})}

These next 2 functions represent the \mbox{\hyperlink{structHuffman}{Huffman}} class in tartarize\textquotesingle{}s code. {\itshape h} \mbox{\Hypertarget{compress_8c_a04af50a7e18d0e4d85ae76c7c4bd80d9}\label{compress_8c_a04af50a7e18d0e4d85ae76c7c4bd80d9}} 
\index{compress.c@{compress.c}!huffman\_lookup@{huffman\_lookup}}
\index{huffman\_lookup@{huffman\_lookup}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{huffman\_lookup()}{huffman\_lookup()}}
{\footnotesize\ttfamily int $\ast$ huffman\+\_\+lookup (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery__internal_8h_a8ad0df962f28b81981b3b0b7f04ebb17}{huffman}}}]{h,  }\item[{int}]{byte\+\_\+lookup }\end{DoxyParamCaption})}

Lookup {\itshape byte\+\_\+lookup} in huffman table {\itshape h} return result as two bytes using the memory huffman\+\_\+lookup\+\_\+data. \mbox{\Hypertarget{compress_8c_a053addffe32629b6727073e9c499cc32}\label{compress_8c_a053addffe32629b6727073e9c499cc32}} 
\index{compress.c@{compress.c}!hus\_compress@{hus\_compress}}
\index{hus\_compress@{hus\_compress}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{hus\_compress()}{hus\_compress()}}
{\footnotesize\ttfamily int hus\+\_\+compress (\begin{DoxyParamCaption}\item[{char $\ast$}]{data,  }\item[{int}]{length,  }\item[{char $\ast$}]{output,  }\item[{int $\ast$}]{output\+\_\+length }\end{DoxyParamCaption})}

{\itshape data} {\itshape length} {\itshape output} {\itshape output\+\_\+length} . Returns whether it was successful as an int.

This avoids the now unnecessary compression by placing a minimal header of 6 bytes and using only literals in the huffman compressed part (see the sources above). \mbox{\Hypertarget{compress_8c_aa5370ff498be6c8a440bb0a581c2ed5c}\label{compress_8c_aa5370ff498be6c8a440bb0a581c2ed5c}} 
\index{compress.c@{compress.c}!hus\_decompress@{hus\_decompress}}
\index{hus\_decompress@{hus\_decompress}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{hus\_decompress()}{hus\_decompress()}}
{\footnotesize\ttfamily int hus\+\_\+decompress (\begin{DoxyParamCaption}\item[{char $\ast$}]{data,  }\item[{int}]{length,  }\item[{char $\ast$}]{output,  }\item[{int $\ast$}]{output\+\_\+length }\end{DoxyParamCaption})}

{\itshape data} {\itshape length} {\itshape output} {\itshape output\+\_\+length} . Returns whether the decompression was successful. 

\doxysubsubsection{Variable Documentation}
\mbox{\Hypertarget{compress_8c_af0a0646ec730d0abdffced84a07f845e}\label{compress_8c_af0a0646ec730d0abdffced84a07f845e}} 
\index{compress.c@{compress.c}!huffman\_lookup\_data@{huffman\_lookup\_data}}
\index{huffman\_lookup\_data@{huffman\_lookup\_data}!compress.c@{compress.c}}
\doxyparagraph{\texorpdfstring{huffman\_lookup\_data}{huffman\_lookup\_data}}
{\footnotesize\ttfamily int huffman\+\_\+lookup\+\_\+data\mbox{[}2\mbox{]}}

